(function () {
    function Role(data) {
        Role.super(this);
        
        this.roleId = data.roleId;
        this.roleName = data.roleName;

        this.role = null;
        this.shadow = null;

        this.init(data);
    }
    Laya.class(Role, "Com.Home.Role", Laya.Sprite);
    var _proto = Role.prototype;
    _proto.init = function (data) {
        if(!data.roleId){
            console.log(new Error("角色皮肤ID不存在"));
            return;
        }
        this.size(260, 400);
        this.anchorX = 0.5;
        this.anchorY = 1;

        this.create();
        this.bindEvent();
    }
    _proto.create = function () {
        var shadow = new Laya.Image("res/public/shadow.png");
            shadow.centerX = 0;
            shadow.anchorY = 1;
            shadow.y = this.height;

        var roleSkin = utils.createSkeleton(ROLE_NORMAL_SKIN_PATH + this.roleId);
            roleSkin.play(0, true);
            roleSkin.y = this.height - shadow.height / 2;
            roleSkin.x = this.width / 2;
        
        this.role = roleSkin;
        this.shadow = shadow;
        this.addChildren(shadow, roleSkin);        
    }
    _proto.bindEvent = function () {
        this.on(Laya.Event.CLICK, this, function () {
            ppt.director.runScene(new Scene.Role);
        });
    }
})();